﻿using LiuQiuRong.Chat.Infrastructures.Dependencies;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace LiuQiuRong.Chat.Repositories
{
    public partial interface IBaseRepository<TEntity> : IRepository where TEntity : class, IEntity, new()
    {
        TEntity GetById<TKey>(TKey id);

        TEntity GetByExpression(Expression<Func<TEntity, bool>> expression);

        int Insert(TEntity entity);

        int Insert<T>(T entity) where T : class, new();

        int Update(TEntity entity);

        int Update<T>(T entity) where T : class, new();

        int UpdateColumns(TEntity entity, Expression<Func<TEntity, object>> columns);

        int UpdateColumns<T>(T entity, Expression<Func<T, object>> columns) where T : class, new();

        int Delete<TKey>(TKey id);

        bool Any(Expression<Func<TEntity, bool>> expression);

        IEnumerable<TEntity> GetList(Expression<Func<TEntity, bool>> expression, string orderBy = null);

        IEnumerable<TEntity> GetList(string expression, string orderBy = null);

        IEnumerable<TEntity> GetListByPage(Expression<Func<TEntity, bool>> expression, string orderBy, int pageIndex, int pageSize, ref int records, ref int totalPage);

        IEnumerable<TEntity> GetListByPage(string expression, string orderBy, int pageIndex, int pageSize, ref int records, ref int totalPage);
    }
}
